core: Ensure we chown created directories too
authorColin Walters <walters@verbum.org>
Wed, 7 Dec 2011 01:16:03 +0000 (20:16 -0500)
committerColin Walters <walters@verbum.org>
Wed, 7 Dec 2011 01:16:03 +0000 (20:16 -0500)
src/libostree/ostree-core.c
src/libostree/ostree-repo.c

index e4fc1f00917e945725e48aaaeeee22673b453dc5..8bd06487c66af73a21658db0aa9030f88821815c 100644 (file)
@@ -884,7 +884,16 @@ ostree_create_file_from_input (GFile            *dest_file,
     }
   dest_path = ot_gfile_get_path_cached (dest_file);
 
-  if (S_ISREG (mode))
+  if (S_ISDIR (mode))
+    {
+      if (mkdir (ot_gfile_get_path_cached (dest_file),
+                 g_file_info_get_attribute_uint32 (finfo, "unix::mode")) < 0)
+        {
+          ot_util_set_error_from_errno (error, errno);
+          goto out;
+        }
+    }
+  else if (S_ISREG (mode))
     {
       out = g_file_create (dest_file, 0, cancellable, error);
       if (!out)
index 2b896a089e970a2ddfed9b0bae660cac3f4eadb0..7c9ef1161c28c959fc00fa4ff7b53dc142499fe6 100644 (file)
@@ -1995,16 +1995,14 @@ checkout_one_directory (OstreeRepo  *self,
   if (!_ostree_repo_file_get_xattrs (dir, &xattr_variant, NULL, error))
     goto out;
 
-  if (mkdir (dest_path, (mode_t)g_file_info_get_attribute_uint32 (dir_info, "unix::mode")) < 0)
-    {
-      ot_util_set_error_from_errno (error, errno);
-      g_prefix_error (error, "Failed to create directory '%s': ", dest_path);
-      goto out;
-    }
-
-  if (!ostree_set_xattrs (dest_file, xattr_variant, cancellable, error))
+  if (!ostree_create_file_from_input (dest_file, dir_info,
+                                      xattr_variant,
+                                      NULL,
+                                      OSTREE_OBJECT_TYPE_FILE,
+                                      NULL,
+                                      cancellable, error))
     goto out;
-      
+
   if (!checkout_tree (self, dir, dest_path, cancellable, error))
     goto out;